package md.frolov.bible.initializers;

public class Attributes{
	private String[] keys = new String[30];
	private String[] values = new String[30];
	private int size;
	
	public void clear() {
		size = 0;
	}

	public boolean containsKey(String arg) {
		for(int i=0;i<size;i++){
			if(keys[i].equals(arg)) return true;
		}
		return false;
	}

	public boolean containsValue(String arg) {
		for(int i=0;i<size;i++){
			if(values[i].equals(arg)) return true;
		}
		return false;
	}

	public String get(String key) {
		for(int i=0;i<size;i++){
			if(keys[i].equals(key)) return values[i];
		}
		return null;
	}

	public boolean isEmpty() {
		return size==0;
	}

	public String put(String key, String value) {
		if(size > keys.length) expand();
		keys[size] = key;
		values[size] = value;
		size++;
		return value;
	}
	
	private void expand(){
		expand(30);
	}
	
	private void expand(int exp){
		String[] oldKeys = keys;
		String[] oldValues = values;
		keys = new String[keys.length+exp];
		values = new String[values.length+exp];
		for(int i=0;i<size;i++){
			keys[i] = oldKeys[i];
			values[i] = oldValues[i];
		}
	}

	public int size() {
		return size;
	}
}
